package zozopo.tools;

import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;

import zozopo.database.LocalDatabaseManager;
import zozopo.manual.operations.ReleaseOS;
import zozopo.manual.operations.ReleaseTB;

public class CreateJspToHtml {
	public static void main(String[] args) throws Exception {
		LocalDatabaseManager localDatabaseManager = new LocalDatabaseManager();
		
		ReleaseOS releaseOS = new ReleaseOS(localDatabaseManager.getConnection());
		
		List<ReleaseTB> list = releaseOS.saerchAllRelease();
		releaseOS.releaseConnection();
		for(ReleaseTB release:list){
			
	
			System.out.println(release.getRelease_id());
			
			URL url = new URL("http://www.zozopo.com/manual/view.action?id="+release.getRelease_id());

			URLConnection conn = url.openConnection();//获得UrlConnection 连接对象
			InputStream is = conn.getInputStream();//获得输入流

			OutputStream os = new FileOutputStream("D:\\manual\\view_id_"+release.getRelease_id()+".html");
			byte[] buffer = new byte[2048];
			int length = 0;
			while(-1 !=(length=is.read(buffer,0,buffer.length))){
				os.write(buffer,0,length);
				System.out.println(is.read());
			}
			System.out.println();
			is.close();
			os.close();//**/
		}
		
		
		
	}
}
